<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="mui/mui.min.css">
    <link rel="stylesheet" href="mui/mui.picker.min.css">
    <link rel="stylesheet" href="mui/mui.showLoading.css">
    <link rel="stylesheet" href="css/myPrize.css??20180821">
    <script src="js/flexible.js"></script>
    <title>我的奖品</title>
</head>

<body>
    <div id="app" class="app">
        <!-- <div class="back" id="back" @click='back'>
            <img src="img/icon_back.png" alt="">
        </div> -->
        <div class="content">
            <div class="title">恭喜您获得了</div>
            <div class="prize_t">
                <img :src='prize_url+"?20180821"' alt="">
            </div>
            <div class="prize_num">{{prize_num}}</div>
            <div class="prize_name">{{prize_name}}</div>
            <div class="btn_x" @click="jump">领取奖品</div>
        </div>
        <div class="footer">
                <div class="img" id="img"><img src="img/right_logo_h.png?20180821" alt=""></div>
        </div>
    </div>
    <script src="mui/mui.min.js"></script>
    <script src="mui/mui.showLoading.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/config.js"></script>
</body>
<script>
    var url=appconfig.apiUrl;
    let vm = new Vue({
        el: "#app",
        data: {
            message: false,
            prize: true,
            prizeMessage: true,
            rulesMessage: true,
            prize_num: "",
            prize_name: "",
            prize_url: "",
            theRequest: "",
            id:"",
            type: ""
        },
        methods: {
            geUrl: function () {
                var theRequest = {};
                var url = decodeURIComponent(location.search); //获取url中"?"符后的字串
                if (url.indexOf("?") != -1) {
                    var str = url.substr(1);
                    var strs = str.split("&");
                    for (var i = 0; i < strs.length; i++) {
                        theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                    }
                }
                return theRequest;
            },
            doRecive() {
                var self=this;
                var param={
                    id:this.id,
                    name:"",//收货人姓名
		            phone:"",//收货人电话
		            province:"",//收货城市
		            city:"",//收货省份
		            region:"",//收货区域
		            address:"",//详细地址
		            zip_code:"",//邮编，可空
                }
                axios({
                    method: "POST",
                    url:url+'/luckdraw/doRecive',
                    data: param
                }).then(function (res) {
                    mui.hideLoading();
                    if (res.data.code == "0") {
                        window.location.href = "receivePrize.html?id=" + self.theRequest.id + "&vip_id=" + self.theRequest.vip_id + "&status=3&t=" + new Date().getTime();
                    }else if(res.data.code=="-1"){
                        mui.alert(res.data.msg," ");
                    }
                }).catch(function (err) {
                    console.log(err);
                    mui.hideLoading();
                    console.log(err);
                    mui.alert("服务器异常", " ")
                });
            },
            jump(val) {
                if (this.type == "1") {
                    window.location.href = "myAddress.html?id=" + this.theRequest.id + "&vip_id=" + this.theRequest.vip_id + "&status=1&t=" + new Date().getTime();
                } else if (this.type == "2") {
                    this.doRecive();
                    // window.location.href = "receivePrize.html?id=" + this.theRequest.id + "&vip_id=" + this.theRequest.vip_id + "&status=3&t=" + new Date().getTime();
                }
            },
            back() {
                if (this.theRequest.status == "1") {
                    window.location.href = "game.html?status=1&t=" + new Date().getTime();
                } else if (this.theRequest.status == "2") {
                    window.location.href = "game.html?status=2&t=" + new Date().getTime();
                } else if (this.theRequest.status == "3") {
                    window.location.href = "game.html?status=3&t=" + new Date().getTime();
                }

            },
            imgUrlf() {
                var pirzeMessage = JSON.parse(localStorage.getItem('pirzeMessage'));
                if (pirzeMessage !== null) {
                    var luck_draw_item_info = pirzeMessage.luck_draw_item_info;
                    var luck_draw_prize_info = pirzeMessage.luck_draw_record_info;
                    console.log(luck_draw_item_info);
                    console.log(luck_draw_prize_info);
                }
                this.prize_url = luck_draw_item_info.prize_url;
                this.prize_name = luck_draw_item_info.name;
                this.type = luck_draw_item_info.type;
                this.prize_num=luck_draw_item_info.grade_name;
                this.id=luck_draw_prize_info.id;
                // if(this.theRequest.status=="1"){
                //     this.prize_num="一等奖",
                //     this.prize_name="苹果iphone x手机",
                //     this.imgUrl='img/phonex.png';
                // }else if(this.theRequest.status=="2"){
                //     this.prize_num="幸运奖",
                //     this.prize_name="长荣航空购票优惠码",
                //     this.imgUrl='img/wxm.png';
                // }else if(this.theRequest.status=="3"){
                //     this.prize_num="三等奖",
                //     this.prize_name="爱奇艺VIP月卡",
                //     this.imgUrl='img/slot4.png';
                // }
            }
        },
        mounted() {
            this.theRequest = this.geUrl();
            this.imgUrlf();
        }
    })
</script>
</script>

</html>